<template>
   <el-card>
     <el-form :model="queryParams" ref="queryParams" :inline="true" label-width="100px">
            <!-- TODO报错 -->
            <!-- <el-form-item label="日志时间">
                <el-date-picker
                    type="datetimerange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期">
                </el-date-picker>
            </el-form-item> -->
            <el-form-item label="服务器IP" prop="chnName">
                <el-input v-model="queryParams.chnName" placeholder="插件描述" size="small"></el-input>
            </el-form-item>
            <el-form-item label="日志等级" prop="chnName">
                <el-input v-model="queryParams.chnName" placeholder="插件描述" size="small"></el-input>
            </el-form-item>
             <el-form-item label="日志内容" prop="chnName">
                <el-input v-model="queryParams.chnName" placeholder="插件描述" size="small"></el-input>
            </el-form-item>
             <el-form-item label="业务ID" prop="chnName">
                <el-input v-model="queryParams.chnName" placeholder="插件描述" size="small"></el-input>
            </el-form-item>
            <el-form-item >
                <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-delete" size="small" @click="resetQuery('queryParams')">清空</el-button>
            </el-form-item>
        </el-form>
          <el-table :data="tableData" border style="width: 100%" size="small">
            <el-table-column type="index" label="#" width="50"></el-table-column>
            <el-table-column label="日志时间" prop="id"></el-table-column>
            <el-table-column label="服务器IP" prop="engName"></el-table-column>
            <el-table-column label="日志等级" prop="chnName"></el-table-column>
            <el-table-column label="业务ID" prop="config"></el-table-column>
          </el-table>
        <el-pagination
                v-show="total>0"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                background
                :current-page="1"
                :page-sizes="[10, 20, 30, 40,50,100]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                class="pagination-container"
                :total="total">
         </el-pagination>
   </el-card>
</template>

<script>
import { getLogList } from '@/api/getway/log.api.js'
    export default {
        data() {
            return {
                tableData: [],
                queryParams: {
                    current: 1,
                    size: 10
                },
                total: 10
            }
        },
        mounted() {
            this.getList();
        },
        methods: {
            async getList() {
                const result = await getLogList(this.queryParams);
                if(result.code === 200) {
                    this.tableData = result.data.records;
                }
            },
            // 搜索
            handleQuery() {
                this.queryParams.current = 1;
                this.getList();
            },
            // 清空
            resetQuery(formName) {
                this.$refs[formName].resetFields();
                this.getList();
            },
              handleSizeChange(val) {
                this.queryParams.size = val;
                this.getList();
            },
            handleCurrentChange(val) {
                this.queryParams.current = val;
                this.getList();
            }
        }
    }
</script>

<style lang="scss" scoped>
.info {
    font-size: 10px;
    opacity: .7;
}
</style>